home *** CD-ROM | disk | FTP | other *** search
/ The Best of MacTutor - S…e Code for Volumes 1 to 5 / The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin / Source Code / #50 (Nov 89) / Alternate Appl / Alternate.c < prev    next >
C/C++ Source or Header  |  1989-08-20  |  3KB  |  91 lines

  1. /************************************************************************/
  2. /*                                                                          */
  3. /*    Source   - Alternate.c                                                */
  4. /*    Author   - Alexander S. Colwell, Copyright (C) 1989                    */
  5. /*                                                                        */
  6. /*    Purpose     - This application will demostrate the AlternateCDEF        */
  7. /*                  scroll bar using THINK C's object stuff.                    */
  8. /*                                                                        */
  9. /************************************************************************/
  10.  
  11. #include <Global.h>                    /* Global variable defs                */
  12. #include <CApplication.h>            /* Application object defs            */
  13. #include <Commands.h>                /* Command object defs                */
  14. #include <CBartender.h>                /* Menu object defs                    */
  15. #include <CDecorator.h>                /* Window display object defs        */
  16. #include <CDesktop.h>                /* Desktop layer object defs        */
  17. #include <CDocument.h>                /* Document object defs                */
  18. #include <CEditText.h>                /* Text edit object defs            */
  19. #include <CScrollPane.h>            /* Scrolling pane object defs        */
  20.  
  21. struct CAltDemoApp : CApplication {    /* Application object                */
  22.     void    CreateDocument(void);    /* Create text edit window method    */
  23.     };
  24.  
  25. struct CAltDemoDoc : CDocument {    /* Document object                    */
  26.     void        NewFile(void);        /* Make new (bogus) file method        */
  27.     };
  28.     
  29. struct CAltDemoPane : CEditText {    /* Text edit pane object            */
  30.     void    IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor);
  31.     };
  32.  
  33. #define    altWIND            500            /* "Alternate Demo" WIND template     */
  34.  
  35.                                     /* Define external references        */
  36. extern    CApplication    *gApplication;/* Application object                */
  37. extern    CDecorator        *gDecorator;/* Window display object            */
  38. extern    CDesktop        *gDesktop;    /* Desktop view layer object         */
  39. extern    CBartender        *gBartender;/* Menu handler object                */
  40.  
  41. void main()
  42.  
  43.     {
  44.         gApplication = new(CAltDemoApp);/* Create new application object*/
  45.         gApplication->IApplication(4,4096L,2048L);/* Init application    */
  46.         gApplication->Run();        /* Startup application execution    */
  47.         gApplication->Exit();        /* Return to da "Finder"            */
  48.     }
  49.  
  50. void CAltDemoApp::CreateDocument()
  51.     {
  52.         CAltDemoDoc    *theDocument;    /* Working new document object        */
  53.     
  54.         theDocument = new(CAltDemoDoc);/* Create new document object    */
  55.         theDocument->IDocument(this,FALSE);/* Initialize document object*/
  56.         theDocument->NewFile();        /* Create new (bogus) document file    */
  57.     }
  58.  
  59. void CAltDemoDoc::NewFile(void)
  60.     {
  61.         CScrollPane        *theScrollPane;    /* Working scroll pane object    */
  62.         CAltDemoPane    *theMainPane;/* Working main pane object        */
  63.     
  64.         itsWindow = new(CWindow);    /* Create new window object            */
  65.         itsWindow->IWindow(altWIND,FALSE,gDesktop,this);
  66.         
  67.         theScrollPane = new(CScrollPane);/* Create window's scrolling obj*/
  68.         theScrollPane->IScrollPane(itsWindow,this,10,10,0,0,sizELASTIC,sizELASTIC,
  69.                                    TRUE,TRUE,TRUE);
  70.         theScrollPane->FitToEnclFrame(TRUE, TRUE);
  71.         theMainPane = new(CAltDemoPane);
  72.         itsMainPane = theMainPane;
  73.         itsGopher = theMainPane;
  74.         theMainPane->IEditPane(theScrollPane,this);
  75.         theScrollPane->InstallPanorama(theMainPane);
  76.     
  77.         itsWindow->Select();        /* Select our window now!!            */
  78.     }
  79.  
  80.  
  81. void CAltDemoPane::IEditPane(CView *anEnclosure, CBureaucrat *aSupervisor)
  82.     {
  83.         Rect    margin;                /* Working margin rect area            */
  84.     
  85.                                     /* Setup text edit stuff            */
  86.         CEditText::IEditText(anEnclosure,aSupervisor,1,1,0,0,sizELASTIC,sizELASTIC,432);
  87.         FitToEnclosure(TRUE,TRUE);
  88.         SetRect(&margin,2,2,-2,-2);
  89.         ChangeSize(&margin,FALSE);
  90.     }
  91.